import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/views/Index'
import Document from '@/views/Document'
import Login from '@/views/Login'
import Register from '@/views/Register'

Vue.use(Router)

export const constantRoutes = [
  {
    path: "/login",
    name: 'Login',
    component: Login,
    hidden: true
  },
  {
    path: "/register",
    name: 'Register',
    component: Register,
    hidden: true
  },
  {
    path: '/',
    name: 'Index',
    component: Index
  },
  {
    path: '/document',
    name: 'Document',
    component: Document
  }
]

const createRouter = () =>
  new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  });

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher;
}

const router = createRouter();

export default router
